package c.j.a.d.b.c;

import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteStatement;

/* compiled from: TableStatements */
public class i {
    public final SQLiteDatabase a;
    public final String b;
    public final String[] c;
    public final String[] d;
    public SQLiteStatement e;
    public SQLiteStatement f;
    public SQLiteStatement g;

    public i(SQLiteDatabase sQLiteDatabase, String str, String[] strArr, String[] strArr2) {
        this.a = sQLiteDatabase;
        this.b = str;
        this.c = strArr;
        this.d = strArr2;
    }

    public SQLiteStatement a() {
        if (this.e == null) {
            String str = this.b;
            String[] strArr = this.c;
            StringBuilder stringBuilder = new StringBuilder("INSERT INTO ");
            stringBuilder.append('\"');
            stringBuilder.append(str);
            stringBuilder.append('\"');
            stringBuilder.append(" (");
            int length = strArr.length;
            for (int i = 0; i < length; i++) {
                stringBuilder.append('\"');
                stringBuilder.append(strArr[i]);
                stringBuilder.append('\"');
                if (i < length - 1) {
                    stringBuilder.append(',');
                }
            }
            stringBuilder.append(") VALUES (");
            int length2 = strArr.length;
            for (int i2 = 0; i2 < length2; i2++) {
                if (i2 < length2 - 1) {
                    stringBuilder.append("?,");
                } else {
                    stringBuilder.append('?');
                }
            }
            stringBuilder.append(')');
            SQLiteStatement compileStatement = this.a.compileStatement(stringBuilder.toString());
            synchronized (this) {
                if (this.e == null) {
                    this.e = compileStatement;
                }
            }
            if (this.e != compileStatement) {
                compileStatement.close();
            }
        }
        return this.e;
    }

    public SQLiteStatement b() {
        if (this.g == null) {
            String str = this.b;
            String[] strArr = this.d;
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.append('\"');
            stringBuilder.append(str);
            stringBuilder.append('\"');
            str = stringBuilder.toString();
            stringBuilder = new StringBuilder("DELETE FROM ");
            stringBuilder.append(str);
            if (strArr != null && strArr.length > 0) {
                stringBuilder.append(" WHERE ");
                c.j.a.c.y.a.i.j(stringBuilder, str, strArr);
            }
            SQLiteStatement compileStatement = this.a.compileStatement(stringBuilder.toString());
            synchronized (this) {
                if (this.g == null) {
                    this.g = compileStatement;
                }
            }
            if (this.g != compileStatement) {
                compileStatement.close();
            }
        }
        return this.g;
    }

    public SQLiteStatement c() {
        if (this.f == null) {
            String str = this.b;
            String[] strArr = this.c;
            String[] strArr2 = this.d;
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.append('\"');
            stringBuilder.append(str);
            stringBuilder.append('\"');
            str = stringBuilder.toString();
            stringBuilder = new StringBuilder("UPDATE ");
            stringBuilder.append(str);
            stringBuilder.append(" SET ");
            for (int i = 0; i < strArr.length; i++) {
                String str2 = strArr[i];
                stringBuilder.append('\"');
                stringBuilder.append(str2);
                stringBuilder.append('\"');
                stringBuilder.append("=?");
                if (i < strArr.length - 1) {
                    stringBuilder.append(',');
                }
            }
            if (strArr2 != null && strArr2.length > 0) {
                stringBuilder.append(" WHERE ");
                c.j.a.c.y.a.i.j(stringBuilder, str, strArr2);
            }
            SQLiteStatement compileStatement = this.a.compileStatement(stringBuilder.toString());
            synchronized (this) {
                if (this.f == null) {
                    this.f = compileStatement;
                }
            }
            if (this.f != compileStatement) {
                compileStatement.close();
            }
        }
        return this.f;
    }
}
